import mitt from 'mitt'

class Bus {
  constructor() {
    this.emitter = mitt()
  }

  on(event, callback) {
    this.emitter.on(event, callback)
  }

  emit(event, data) {
    this.emitter.emit(event, data)
  }

  off(event) {
    this.emitter.off(event)
  }

  clear() {
    this.emitter.all.clear()
  }
}

export default new Bus()
